import React, { Component } from 'react'
import {
    Switch,
    Route,
    Redirect
} from 'react-router-dom'


export default class Routerview extends Component {
    static defaultProps = {
        routes: [],
    }

    render() {
        const { routes } = this.props
        return (
            <Switch>
                {
                    routes.length && routes.map((item, idx) => {
                        // if (item.path && item.path === '/home/my' && !localStorage.getItem("user")) {
                        //     return <Redirect key={idx} to="/login"></Redirect>
                        // }
                        return item.path ? <Route key={idx} path={item.path} render={(props) => <item.component {...props} routes={item.children}></item.component>}></Route>
                            : <Redirect key={idx} exact {...item}></Redirect>
                    })
                }
            </Switch>
        )
    }
}